<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('通道订单列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="form-content">
            <form id="formId" class="form-horizontal">
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">商户代理：</label>
                            <div class="col-sm-8">
                                <select name="agentUserId" class="form-control">
                                    <option value=""></option>
                                    <option th:each="user:${proxys}" th:value="${user.userId}" th:text="${user.userName}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">收款账号：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="text" name="account" class="form-control"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">商户：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="text" name="businessName" class="form-control"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">用户类型：</label>
                            <div class="col-sm-8">
                                <select name="bankName" class="form-control">
                                    <option value=""></option>
                                    <option value="真人">真人</option>
                                    <option value="假人">假人</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">平台订单号：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="text" name="ptOrderno" class="form-control"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">下游订单号：</label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <input type="text" name="childOrderno" class="form-control"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">订单状态：</label>
                            <div class="col-sm-8">
                                <select name="orderStatus" class="form-control">
                                    <option value="">所有</option>
                                    <option value="0">支付中</option>
                                    <option value="1">已支付</option>
                                    <option value="2">手动补单</option>
                                    <option value="3">已成功,未上分</option>
                                    <option value="4">失效</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label ">创建开始时间：</label>
                            <div class="col-sm-4">
                                <div class="input-group select-time">
                                    <input type="text" autocomplete="off" class="time-input form-control"
                                           placeholder="开始时间"
                                           name="params[beginTime]"/>
                                </div>
                            </div>
                            <label class="col-sm-2 control-label">创建结束时间</label>
                            <div class="col-sm-4">
                                <div class="input-group select-time">
                                    <input type="text" class="time-input form-control" autocomplete="off"
                                           placeholder="结束时间"
                                           name="params[endTime]"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">支付类型：</label>
                            <div class="col-sm-8">
                                <select  id="payType"  name="payType"  class="form-control">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${payerPayTypes}" th:text="${dict.payLabel}" th:value="${dict.payType}"></option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-4 col-md-offset-1">
                        <div class="form-group">
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-success btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </div>
                    </div>
                </div>

                <div class="select-list">
                    <!--<ul>-->
                        <!--<li>-->
                            <!--代理商：<select name="agentUserId">-->
                            <!--<option value=""></option>-->
                            <!--<option th:each="user:${proxys}" th:value="${user.userId}" th:text="${user.userName}"></option>-->
                        <!--</select>-->
                        <!--<li>-->
                            <!--码商代理：<select name="channelUserId">-->
                            <!--<option value=""></option>-->
                            <!--<option th:each="user1:${channels}" th:value="${user1.userId}" th:text="${user1.userName}"></option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--商户：<input type="text" name="businessName"/>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--收款账号：<input type="text" name="account"/>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--平台订单号：<input type="text" name="ptOrderno"/>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--下游订单号：<input type="text" name="childOrderno"/>-->
                        <!--</li>-->
                        <!--<li class="select-time">-->
                            <!--<label>创建时间： </label>-->
                            <!--<input type="text" class="time-input" id="startTime" placeholder="开始时间"-->
                                   <!--name="params[beginTime]"/>-->
                            <!--<span>-</span>-->
                            <!--<input type="text" class="time-input" id="endTime" placeholder="结束时间"-->
                                   <!--name="params[endTime]"/>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--订单状态：<select name="orderStatus">-->
                            <!--<option value="">所有</option>-->
                            <!--<option value="0">支付中</option>-->
                            <!--<option value="1">已支付</option>-->
                            <!--<option value="2">手动补单</option>-->
                            <!--<option value="3">已成功,未上分</option>-->
                            <!--<option value="4">失效</option>-->
                        <!--</select>-->
                        <!--</li>-->
                        <!--<li>-->
                            <!--支付类型：<select  id="payType"  name="payType">-->
                            <!--<option value="">所有</option>-->
                            <!--<option th:each="dict : ${payerPayTypes}" th:text="${dict.payLabel}" th:value="${dict.payType}"></option>-->
                        <!--</select>-->
                        <!--</li>-->

                        <!--<li>-->
                            <!--<a class="btn btn-success btn-rounded btn-sm" onclick="$.table.search()"><i-->
                                    <!--class="fa fa-search"></i>&nbsp;搜索</a>-->
                            <!--<a class="btn btn-success btn-rounded btn-sm" onclick="$.form.reset()"><i-->
                                    <!--class="fa fa-refresh"></i>&nbsp;重置</a>-->
                        <!--</li>-->
                    <!--</ul>-->
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.table.exportExcel()"
               shiro:hasPermission="channel:channelOrder:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('channel:channelOrder:edit')}]];
    var roleKey = [[${roleKey}]];
    var detailFlag = [[${@permission.hasPermi('channel:channelOrder:list')}]];
    var datastatus = [[${@dict.getType('sys_order_status')}]];
    var prefix = ctx + "channel/channelOrder";

    $(function () {
        var options = {
            url: prefix + "/list/success",
            createUrl: prefix + "/add",
            detailUrl: prefix + "/detail/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            setpayUrl: prefix + "/setpay",
            modalName: "通道订单",
            sortName: "submitTime",
            sortOrder: "desc",
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'ptOrderno',
                    title: '平台订单号',
                    sortable: true
                },
                {
                    field: 'childOrderno',
                    title: '下游订单号',
                    sortable: true
                },
                {
                    field: 'bankName',
                    title: '用户类型',
                    formatter: function (value) {
                        return value === '假人'? '<span style="color: red">假人</span>' : '真人'
                    },
                },
                {
                    field: 'ddId',
                    title: '手动上分',
                    formatter: function (value) {
                        return value === 1 ? '<span style="color: red">手动上分</span>' : '<span style="color: mediumseagreen">正常订单</span>'
                    },
                },
                {
                    field: 'businessName',
                    title: '商户名称',
                    sortable: true
                },
                {
                    field: 'agentUserName',
                    title: '业务员',
                    sortable: true
                },
                {
                    field: 'amount',
                    title: '交易金额',
                    sortable: true
                },
                {
                    field: 'payAmount',
                    title: '实际金额',
                    sortable: true
                },
                {
                    field: 'submitTime',
                    title: '提交日期',
                    sortable: true
                },
                {
                    field: 'successTime',
                    title: '成功日期',
                    sortable: true
                },
                {
                    field: 'account',
                    title: '交易账号',
                    sortable: true
                },
                {
                    field: 'submitUrl',
                    title: '提交地址',
                    visible: false
                },
                {
                    field: 'returnUrl',
                    title: '页面返回地址',
                    visible: false
                },
                {
                    field: 'serverUrl',
                    title: '服务器通知地址',
                    visible: false
                },
                {
                    field: 'orderStatus',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datastatus, value);
                    },
                    sortable: true
                },
                {
                    field: 'status',
                    title: '数据状态',
                    visible: false
                },
                {
                    field: 'createBy',
                    title: '创建者',
                    visible: false
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    visible: false
                },
                {
                    field: 'updateBy',
                    title: '修改者',
                    visible: false
                },
                {
                    field: 'updateTime',
                    title: '修改时间',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(roleKey == 'admin2' || roleKey == 'admin' || roleKey == 'channel'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="addOrder(\'' + row.orderId + '\',\'' + row.orderStatus + '\')"><i class="fa fa-check"></i>补单</a> ');
                        }
                        if(row.payType == '23'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="getWbDetail(\'' + row.orderId + '\',\'' + row.orderStatus + '\')"><i class="fa fa-check"></i>收款详情</a> ');
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function getWbDetail(orderId) {
        var url = ctx + "channel/channelAccountWb/" + orderId;
        $.modal.openTab("微博收款", url);
    }
    /*已支付*/
    function addOrder(id, status) {
        if (status == 1) {
            $.modal.alertWarning("该订单已成功,无需补单！");
            return;
        }
        var url = prefix + '/edit/' + id;
        $.modal.open("补单操作", url);
    }

    window.setInterval(function(){
        $.table.refresh();
    }, 600000)
</script>
</body>
</html>